package com.christina.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * AI配置类
 * 
 * @author Christina
 */
@Configuration
public class AiConfig {
    
    /**
     * 配置聊天客户端
     * 只有在配置了API Key时才创建
     * 
     * @param openAiChatModel OpenAI聊天模型
     * @return ChatClient实例
     */
    @Bean
    @ConditionalOnProperty(name = "spring.ai.openai.api-key")
    public ChatClient chatClient(OpenAiChatModel openAiChatModel) {
        return ChatClient.builder(openAiChatModel).build();
    }
}